program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i, j: integer;
  mass: array of integer;
  flag: boolean;
begin
  flag:=false;
  readln(n);
  setlength(mass, n);
  for i:=0 to n-1 do
    read(mass[i]);
  for i:=0 to n-1 do
  begin
    for j:=i to n-1 do
    begin
      if (mass[i]+mass[j]=1000) and (flag=false) then
      begin
        writeln(mass[i], ' ', mass[j]);
        flag:=true;
      end;
    end;
  end;
  readln;
  readln;
end.
 